<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>专题活动</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../module/inventory/css/admin/index.css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script language="javascript" src="../script/Calendar.js"></script>
<script type="text/javascript" src="../module/inventory/scripts/yui/yahoo-dom-event/yahoo-dom-event.js" ></script>
<script type="text/javascript" src="../module/inventory/scripts/yui/dragdrop/dragdrop-min.js" ></script>
<script type="text/javascript" src="../module/inventory/scripts/yui/calendar/calendar-min.js"></script>
<script type="text/javascript" src="../module/inventory/scripts/index.js"></script>
<script type="text/javascript" src="../script/jquery.validation.min.js"></script>
<script src="../script/my_lightbox.js" language="javascript"></script>

<script>
$(function(){
	$('#form').validate({
		errorPlacement: function(error, element){
			element.next('.form-error').append(error);
		},      
		rules : {
			title:{
				required:true
			},
			stime:{
				required:true
			},
			etime:{
				required:true
			},
		},
		messages : {
			title:{
				required:'请填写标题',
			},
			etime:{
				required:'请填写开始时间',
			},
			stime:{
				required:'请填写结束时间',
			}
		}
	});
	$('#type').change(function(){
		var s=$(this).val();
		$('span[id^=type_]').hide()
		if(s!=0){
			$('#type_'+s).show();
		}
		
		
	});
	
	//删除新增的楼层节点
    $('.delfloor').live("click",function(){
        $(this).parent().parent().remove();
     });
	
});

//添加楼层
function _addfloor(){
    $('.floor_box').append('<tr><td><input type="text" name="new_floor[]" class="text"  value="" /></td><td><input type="text" name="new_fbgcolor[]" class="text" value="" /> </td><td><input type="text" name="new_fdisplayorder[]" class="text" value="" /> </td><td><img class="delfloor" src="../image/admin/delete.png"></td></tr>');
}

</script>
<style>
.delfloor{
	cursor:pointer;
}
</style>
</head>
<body>
	<div class="container">
        <div class="flow">
            <div class="itemtitle">
                <h3>专题活动</h3>
                <ul>
                    <li <{if $smarty.get.operation==''}>class="current"<{/if}>><a href="?m=activity&s=special.php"><span>管理</span></a></li>
                    <li <{if $smarty.get.operation=='add'}>class="current"<{/if}>><a href="?m=activity&s=special.php&operation=add"><span>添加</span></a></li>
                    <{if $smarty.get.operation=='edit'}>
                    <li class="current"><a href="#"><span>修改</span></a></li>
                    <{/if}>
                </ul>
            </div>
        </div>
        <div class="h35"></div>  
        <{if $smarty.get.operation=='add' or $smarty.get.operation=='edit' }>
            <form name="form" id="form" method="post">
            <input name="id" type="hidden" id="id" value="<{$de.id}>">
            <table class="table">
                <thead>
                    <tr>
                        <th class="partition" colspan="99">专题活动</th>
                    </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="100">标题</td>
                    <td>
                    <input name="title" id="title" type="text" class="w350" value="<{$de.title}>"><div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                <tr>
                    <td>起止时间</td>
                    <td>
                    <script language="javascript">
                    var cdr = new Calendar("cdr");
                    document.write(cdr);
                    cdr.showMoreDay = true;
                    </script>
                    <input onFocus="cdr.show(this);" class="ltext" type="text" name="stime" id="stime" value="<{$de.start_time|date_format}>"> 
                    <{html_select_time use_24_hours=true display_seconds=false prefix=start time=$de.start_time}>
                    - 
                    <input onFocus="cdr.show(this);" class="rtext" type="text" name="etime" id="etime" value="<{$de.end_time|date_format}>">
                    <{html_select_time use_24_hours=true display_seconds=false prefix=end time=$de.end_time}>
                    <div id="form-error" class="form-error"></div>
                    </td>
                </tr>
                
                
                
               <tr>
                    <td>促销类型</td>
                    <td>
                        <select class="select"  name="type" id="type">
                        <option  <{if $de.type==0}>selected="selected"<{/if}>  value="0">无促销</option>
                        <option  <{if $de.type==1}>selected="selected"<{/if}>  value="1">直降</option>
                        <option  <{if $de.type==2}>selected="selected"<{/if}>  value="2">满减</option>
                        </select>
                        <span id="type_1" <{if $de.type!=1}>style="display:none;"<{/if}>>
                       		直降：  <input type="text" class="w60" name="type_config_1" value="<{$de.type_config_1.0.0}>"/>
                        
                        </span>
                        <span id="type_2" <{if $de.type!=2}>style="display:none;"<{/if}>>
                        	<br/>
                       		<br/>满：  <input type="text" class="w60" name="type_config_2[0][0]" value="<{$de.type_config_2.0.0}>"/> 减： <input type="text" class="w60" name="type_config_2[0][1]" value="<{$de.type_config_2.0.1}>"/>
                        	<br/>满：  <input type="text" class="w60" name="type_config_2[1][0]" value="<{$de.type_config_2.1.0}>"/> 减： <input type="text" class="w60" name="type_config_2[1][1]" value="<{$de.type_config_2.1.1}>"/>
                        	<br/>满：  <input type="text" class="w60" name="type_config_2[2][0]" value="<{$de.type_config_2.2.0}>"/> 减： <input type="text" class="w60" name="type_config_2[2][1]" value="<{$de.type_config_2.2.1}>"/>
                        
                        </span>
                    </td>
                </tr>
                <tr>
                    <td>优惠券场景名称</td>
                    <td><input name="cpns_event_key" id="cpns_event_key" type="text" class="w350" value="<{$de.cpns_event_key}>"></td>
                </tr>
                <tr>
                    <td>背景色值</td>
                    <td><input name="bgcolor" id="bgcolor" type="text" class="w350" value="<{$de.bgcolor}>"></td>
                </tr>
                <tr>
                    <td>商品楼层</td>
                    <td width="300" height="300">
                                    <div>
            <table>
                <thead>
                <tr>
                    <td>楼层名称</td>
                    <td>背景色值</td>
                    <td>楼层顺序</td>
                    <td><a href="javascript:void(0);" onclick="_addfloor();" ><img src="../image/admin/addchildboard.png"></a></td>
                </tr> 
                </thead>
                <tbody class="floor_box">
                <{foreach item=floor from=$de.floors}>
                <tr>
                    <td><input type="text" name="floor[<{$floor.id}>]" class="text"  value="<{$floor.title}>" /></td>
                    <td><input type="text" name="fbgcolor[<{$floor.id}>]" class="text" value="<{$floor.bgcolor}>" /> </td>
                    <td><input type="text" name="fdisplayorder[<{$floor.id}>]" class="text" value="<{$floor.displayorder}>" /> </td>
                    <td><a onclick="return confirm('确定删除吗');" href="?m=activity&s=special.php&operation=edit&editid=<{$de.id}>&act=delfloor&id=<{$floor.id}>"><img src="../image/admin/delete.png"></a></td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td><input type="text" name="new_floor[]" class="text"  value="" /></td>
                    <td><input type="text" name="new_fbgcolor[]" class="text" value="" /> </td>
                    <td><input type="text" name="new_fdisplayorder[]" class="text" value="" /> </td>
                    <td><img class="delfloor" src="../image/admin/delete.png"></td>
                </tr>
                <{/foreach}>
                </tbody>
            </table>
            </div>
                    </td>
                </tr>
                 <tr>
                    <td>展示模版</td>
                    <td>
                        <select class="select"  name="templates">
                        	<{foreach item=list from=$de.temp}>
                        	<option value="<{$list.id}>" <{if $list.id==$de.templates}>selected<{/if}>>
                        	<{$list.title}>
                        	
                        	</option>
                        	<{/foreach}>
                        </select>
                        </td>
                        </tr>
                <tr>
                    <td>关联分类</td>
                    <td>
                <select class="ws350" name='catid' >
                <option value='-1'>手选单品</option>
                    	<option value='0' <{if $de.catid==0}>selected="selected" <{/if}>>全部分类</option>
                        <{foreach item=list from=$de.cat}>
             			<option <{if $de.catid==$list.catid }> selected="selected" <{/if}> value="<{$list.catid}>"><{$list.cat}></option>
             			<{foreach item=slist from=$list.scat}>
                            <option <{if $de.catid==$slist.catid}> selected="selected" <{/if}> value="<{$slist.catid}>">|__<{$slist.cat}></option>
                            	    
                                    <{foreach item=lists from=$slist.scat}>
                                    <option <{if $de.catid==$lists.catid}> selected="selected" <{/if}> value="<{$lists.catid}>">|____<{$lists.cat}></option>
                            		<{/foreach}> 
                                    
                            <{/foreach}> 
             			<{/foreach}>
            		</select> 
            		<a href="#" title="关联分类后整个分类的商品全部参加促销活动，如果选择全部分类，为全站活动，如果自选单品则可以在列表页选择参加活动的商品"><img border="0" src="../image/admin/Help Circle.jpg" style="vertical-align:middle;"></a>
            		   
                 </td>
                </tr>
                <tr>
                    <td>专题描述</td>
                    <td>
                    	<script charset="utf-8" src="../lib/kindeditor/kindeditor-min.js"></script>
						
                    	<script>
						var editor;
						KindEditor.ready(function(K) {
							editor = K.create('textarea[name="desc"]', {
								resizeType : 1,
								allowPreviewEmoticons : false,
								allowImageUpload : false,
								filterMode : false,
								langType :'<{$config.language}>',
							});
						});
						</script>
                        <textarea style="width:80%; height:300px" name="desc"><{$de.desc}></textarea>
                    </td>
				</tr>
                <tr>
                    <td>专题头图</td>
                     <td>
                    <input name="pic" class="w350" type="text" id="pic" value="<{$de.pic}>" />
                    [<a href="javascript:uploadfile('上传图片','pic',0,0,'activity')">上传</a>] 
                    [<a href="javascript:preview('pic');">预览</a>]
                    [<a onclick="javascript:$('#pic').val('');" href="#">删除</a>] <span class="bz"></span>
                    </td>
                </tr>
                
                <tr>
                    <td>展示状态</td>
                    <td>
                    <input type="radio" name="status" value="1" id="open" <{if $de.status==1}>checked="checked"<{/if}>/><label for="open">开启</label>
                     <input type="radio" name="status" value="2" id="open" <{if $de.status==2}>checked="checked"<{/if}>/><label for="open">推荐</label>
                    <input type="radio" name="status" value="0" id="close" <{if $de.status==0}>checked="checked"<{/if}>/><label for="close">关闭</label>
                    </td>
                </tr>
                <tr>
                    <td>seo_title</td>
                    <td><input type="text" name="seo_title" size="45" value="<{$de.seo_title}>"/></td>
                </tr>
                <tr>
                    <td>seo_keywords</td>
                    <td><textarea name="seo_keywords" id="seo_keywords" cols="45" rows="5" class="text" ><{$de.seo_keywords}></textarea></td>
                </tr>
                <tr>
                    <td>seo_description</td>
                    <td><textarea name="seo_description" id="seo_description" cols="45" rows="5" class="text"><{$de.seo_description}></textarea></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>
                    <input class="submit" type="submit" value="提交">
                    <input name="act" type="hidden" id="action" value="<{if !$smarty.get.editid}>save<{else}>edit<{/if}>">
                    </td>
                </tr>
                </tbody>
            </table>
            </form>
        <{else}>
		<script type="text/javascript">
        $(function(){
            /* 全选 */
             $('.checkall').click(function(){
                var _self = this;
                $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                        $(this).attr('checked', _self.checked);
                    }
                });
                $('.checkall').attr('checked', this.checked);
            });	 
        });
        </script>
        <form action="" method="get">
    <input type="hidden" name="m" value="activity">
    <input type="hidden" name="s" value="special.php">
    <table class="select_table">
        <tbody>
            <tr>
                <td width="60">时间:</td>
                <td class="yui-skin-sam" width="200">
                	<input id="sdate" name="sdate" type="text" size="12" value="<{$smarty.get.sdate}>" onfocus="lockinput(this)" />
                	<input id="edate" name="edate" type="text" size="12" value="<{$smarty.get.edate}>" onfocus="lockinput(this)" />
            		<div id="calContainer" style="display:none; position:absolute;"></div>
            	</td>
            	
            	
            	 <td width="60">是否开始：</td>
                
                <td width="80">
                    <select name="is_start" id="is_start">
                        <option value="">全部</option>
                        <option value="1" <{if "1"===$smarty.get.is_start}>selected="selected"<{/if}>>进行中</option>
                        <option value="2" <{if "2"===$smarty.get.is_start}>selected="selected"<{/if}>>未开始</option>
                        <option value="-1" <{if "-1"==$smarty.get.is_start}>selected="selected"<{/if}>>已结束</option>
                    </select>
                </td>
            	
                <td width="60">状态：</td> 
                
                <td width="80">
                	<select name="statu" id="statu">
                		<option value="">全部</option>
                		<option value="1" <{if "1"===$smarty.get.statu}>selected="selected"<{/if}>>开启</option>
                		<option value="2" <{if "2"===$smarty.get.statu}>selected="selected"<{/if}>>推荐</option>
                		<option value="0" <{if "0"==$smarty.get.statu}>selected="selected"<{/if}>>关闭</option>
                	</select>
                </td>
                <td><input type="image" src="<{$config.weburl}>/image/admin/search.gif" /></td>
            </tr>
            
        </tbody>
    </table>
    </form>
        <form action="" method="post">
        <table class="table">
        	<thead>
                <tr>
                    <th class="partition" colspan="99">活动列表</th>
                </tr>
            </thead>
            <tbody>
                <tr class="header">
                    <th width="30"></th>
                    <th width="70">显示顺序</th>
                    <th width="50">专题ID</th>
                    <th>标题</th>
                    <th width="150">起止时间</th>
                    <th width="60">促销类型</th>
                    <th width="170">分类</th>
                    <th width="60">状态</th>
                    
                    <th width="100">操作</th>
                </tr>
                <{foreach item=list from=$de.list}>
                <tr>
                    <td><input type="checkbox" value="<{$list.id}>" class="checkitem" name="chk[]"></td>
                    <td><input type="text" class="w50" maxlength="3" name="displayorder[<{$list.id}>]" value="<{$list.displayorder}>" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d]/g,'')" /></td>
                    <td><{$list.id}></td>
                    <td><{$list.title}></td>
                    <td><{$list.start_time|date_format:"%Y-%m-%d %H:%M"}> <br/> <{$list.end_time|date_format:"%Y-%m-%d %H:%M"}></td>
                    <td><{if $list.type=='1' }>直降<{elseif $list.type=='2'}>满减<{elseif $list.type=='3'}>满赠<{else}>无促销<{/if}></td>
                    <td>&nbsp;<{if $list.catid==0}>全分类<{elseif $list.catid==-1}>单品<{else}><{$list.cat}><{/if}></td>
                    <td><{if $list.status==1}>开启<{elseif $list.status==2}>推荐<{else}>关闭<{/if}></td>
                 
                    <td>
                    <a title="添加分享数据" href="?m=share_data&s=share_data_add_edit.php&operation=add&share_url=/special-<{$list.id}>.html"><{$addimg}></a>
                    <a href="?m=activity&s=special.php&operation=edit&editid=<{$list.id}><{$cond}>"><{$editimg}></a> 
                    <a onclick="return confirm('确定删除吗');" href="?m=activity&s=special.php&delid=<{$list.id}><{$cond}>"><{$delimg}></a>
                    <{if $list.catid==-1}><a href='?m=activity&s=special_product_list.php&editid=<{$list.id}><{$cond}>'><{$setimg}></a><{/if}>
                    
                    </td>
                </tr>
                <{foreachelse}>
                <tr>
                    <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <{/foreach}>
            </tbody>
            <tfoot>
                <tr>
                	<td colspan="99">
                        <input type="checkbox" class="checkall" id="del">
                        <input type="hidden" name="act" value="op" />
                        <input type="submit" value="提交" />
                    	<div class="page"><{$de.page}></div>
                    </td>
                </tr>
            </tfoot>
        </table>
        </form>
        <{/if}>
    </div>
</body>
</html>